<template>
  <div class="wrap">
    <van-nav-bar
      title="我的社区"
      placeholder
      fixed
      left-arrow
      style="background: #fff"
      @click="toBack"
    />
    <div class="wrap_cont">
      <van-cell
        is-link
        v-for="(item, i) in list"
        :key="i"
        @click="toDetail(item)"
      >
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <img :src="item.img" alt="" width="40px" height="40px" />
          <span class="custom-title">{{ item.label }}</span>
        </template>
      </van-cell>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const toBack = () => {
  window.history.back();
};
const getImg = (name) => {
  return `/src/assets/images/${name}.png`;
};
const list = [
  {
    label: "我的问答",
    img: getImg("sq_04"),
    url: "/wd-wenda",
  },
  {
    label: "我的动态",
    img: getImg("sq_02"),
  },
  {
    label: "我的话题",
    img: getImg("sq_01"),
  },
  {
    label: "我的话题组",
    img: getImg("sq_03"),
  },
];
const toDetail = (value) => {
  router.push({
    path: value.url,
  });
};
</script>

<style lang="scss" scoped>
.wrap {
  &_cont {
    margin-top: 4px;
    ::v-deep(.van-cell) {
      height: 56px;
      justify-content: center;
    }
    ::v-deep(.van-cell__title) {
      display: flex;
      align-items: center;
    }
    .custom-title {
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #272b2d;
      margin-left: 8px;
    }
  }
}
</style>
